package com.mzx.javase.duotai;

/**
 * @Description:
 * @Date: 2021/11/19 15:33
 * @Author: MarKing
 */
public class Demo_Polymorphic {
    public static void show(Animal animal) {
//        animal.eat();
        if (animal instanceof Cat) {
            Cat cat = (Cat) animal;
            cat.work();
        }
        if (animal instanceof Dog) {
            Dog dog = (Dog) animal;
            dog.work();
        }
        animal.eat();
    }
    public static void main(String[] args) {
       show(new Animal());
       show(new Dog());
       show(new Cat());

    }
}
